<?php
namespace application;

use system\libraries\Acl;
use system\libraries\Translation;

/**
 * Bootstrapper for your application
 */
class Hosselaar
{
    /**
     * Initialize your application here
     * 
     * @access public
     */
    public function __init()
    {
        // Creating a new Acl instance (Access Control List)
        $acl = new Acl();
        
        $guest = $acl->addRole('guest');
        $user  = $acl->addRole('user', 'guest');
        
        /**
         * Allow
         */
        $acl->allow($guest, null, 'index');
        $acl->allow($guest, 'users', 'login');
        
        $acl->allow($user, 'users', array('edit/12', 'view', 'logout'));
        
        /**
         * Deny
         */
        $acl->deny($user, 'users', 'login');
        
        
        $acl->setRedirectUrl( base_url('access_denied') );
        
        $acl->checkAcl(function( $role ) {
            throw new \Exception('You ('.$role.') are not allowed to view this page!');
        });
    }
}

/* End of file Bootstrap.php */
